import { GTextFormat } from "../../../../common/GTextFormat";
import { ObjCreate } from "../../common/ObjCreate";
import { LoaderManager } from "../../../../../com/gengine/resource/LoaderManager";
import { ImageInfo } from "../../../../../com/gengine/resource/info/ImageInfo";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GLabel } from "../../../../../com/mui/controls/GLabel";
type int = number;
//class CopyAccountLabel
    
    export  class CopyAccountLabel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._tf = new GTextFormat();
            this._tf.font = "黑体";
            this._tf.size = 25;
            this._tf.color = 16772117;
            this.createChildren();
            return;
        }

        /* internal  */createChildren(): void
        {
            this._leftLabel = ObjCreate.createLabel("", 0, 0, 100, 20, flash.text.TextFormatAlign.LEFT);
            this._leftLabel.textField.filters = [new Object /* flash.filters.GlowFilter */(10690304, 1, 2, 2, 10)];
            this._typeBmp = new Object /* flash.display.Bitmap */();
            this._typeBmp.x = 0;
            this._typeBmp.y = 0;
            this._accountLabel = ObjCreate.createLabel("", 150, -7, 130, 35, flash.text.TextFormatAlign.LEFT, this);
            this._accountLabel.textField.filters = [new Object /* flash.filters.GlowFilter */(10690304, 1, 2, 2, 10)];
            return;
        }

        public set countText(arg1: int)
        {
            this._accountLabel.text = String(arg1);
            this._accountLabel.textField.setTextFormat(this._tf);
            return;
        }

        public startCount(arg1: string, arg2: int, arg3: Boolean=true): void
        {
            this._count = arg2;
            if (arg2 < 100) 
            {
                this._interval = 1;
            }
            else if (arg2 < 300) 
            {
                this._interval = 2;
            }
            else if (arg2 < 3000) 
            {
                this._interval = 10;
            }
            else 
            {
                this._interval = 100;
            }
            if (arg3) 
            {
                this.addChild(this._typeBmp);
                LoaderManager.instance.load(arg1, this.onloadComplete);
            }
            else 
            {
                this._leftLabel.text = arg1;
                this.addChild(this._leftLabel);
                this.onloadComplete();
            }
            return;
        }

        public reset(): void
        {
            this._accountLabel.text = "";
            if (this.bmpUint && this.bmpUint.parent) 
            {
                this.bmpUint.parent.removeChild(this.bmpUint);
            }
            this._interval = 100;
            return;
        }

        /* internal  */onloadComplete(arg1: ImageInfo=null): void
        {
            if (arg1) 
            {
                this._typeBmp.bitmapData = arg1.bitmapData;
            }
            this._currentCount = 0;
            this.countText = this._currentCount;
            this._timer = new Object /* flash.utils.Timer */(this._delayTime);
            this._timer.addEventListener(flash.events.TimerEvent.TIMER, this.onTimerEvent);
            this._timer.start();
            return;
        }

        /* internal  */onTimerEvent(arg1: Object /* flash.events.TimerEvent */): void
        {
            if (this._currentCount >= this._count) 
            {
                this.countText = this._count;
                if (this.showUnit == 1) 
                {
                    this.bmpUint = GlobalClass.getBitmap(ImagesConst.Tongqian);
                    this.bmpUint.x = this._accountLabel.x + this._accountLabel.text.length * 15;
                    this.bmpUint.y = 0;
                    this.addChild(this.bmpUint);
                }
                if (this.showUnit == 2) 
                {
                    this.bmpUint = GlobalClass.getBitmap(ImagesConst.Tongqian_bind);
                    this.bmpUint.x = this._accountLabel.x + this._accountLabel.text.length * 15;
                    this.bmpUint.y = 0;
                    this.addChild(this.bmpUint);
                }
                this._timer.stop();
                this._timer.removeEventListener(flash.events.TimerEvent.TIMER, this.onTimerEvent);
                this._timer = null;
                this.dispatchEvent(new Object /* flash.events.Event */(CopyAccountLabel.CopyAccount_CountComplete));
                return;
            }
            this._currentCount = this._currentCount + this._interval;
            this.countText = this._currentCount;
            return;
        }

        public static /* const */CopyAccount_CountComplete: string="CopyAccountLabel.CopyAccount_CountComplete";

        public static /* const */None: int=0;

        public static /* const */Coin: int=1;

        public static /* const */Coin_Bind: int=2;

        /* internal */ /* var */_leftLabel: GLabel;

        /* internal */ /* var */_typeBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_accountLabel: GLabel;

        /* internal */ /* var */_currentCount: int;

        /* internal */ /* var */_count: int;

        /* internal */ /* var */_tf: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_timer: Object /* flash.utils.Timer */;

        /* internal */ /* var */_delayTime: int=20;

        /* internal */ /* var */_interval: int=100;

        public /* var */showUnit: int=0;

        /* internal */ /* var */bmpUint: Object /* flash.display.Bitmap */;
    }
